#ifndef _SPRITE_H_
#define _SPRITE_H_

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "vg.h"

typedef struct {
  int x, y;            ///< current sprite position
  int width, height;   ///< sprite dimensions
  int xspeed, yspeed;  ///< sprite current speed in the x and y direction
  char *map;           ///< the sprite pixmap (use read_xpm())
} Sprite;

#define MAX_SPEED 5    /**< each sprite maximum speed in pixels/frame */
#define RIGHT_HIT 2    /**< collision with right block (WHITE)  */
#define LEFT_HIT 3     /**< collision with left block (WHITE)   */
#define MOUSE_HIT 4    /**< collision with mouse (LIGHTMAGENTA) */

/** Reads a xpm-like sprite defined in "map" (look at pixmap.h for
 * examples). Returns the address of the allocated memory where the
 * sprite was read. Updates "width" and "heigh" with the sprite
 * dimension.  Return NULL on error.
 * Assumes that VRES and HRES (the screen vertical and horizontal resolution)
 * are externaly defined.
 * 
 * Usage example, using the defined sprite in pixmap.h:
 * <pre>
 *   #include "pixmap.h" // defines  pic1, pic2, etc 
 *   int wd, hg;
 *   char *sprite = read_xpm(pic1, &wd, &hg);
 * </pre>
*/
char *read_xpm(char *map[], int *width, int *height);

Sprite * create_sprite(char *pic[]);

void draw_sprite( Sprite *sprt, char *base);

void destroy_sprite(Sprite *fig);


#endif

